<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<!--<li>-->
								<!--父id：<input type="text" name="parentId"/>-->
							<!--</li>-->

							<li>
								部门名称：<select name="deptId" th:with="type=${@dict.selectDeptName()}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.deptName}" th:value="${dict.deptId}"></option>
							</select>

							</li>

							<li>
								服务项名称：<input type="text" name="siName"/>
							</li>

							<!--<li>-->
								<!--显示顺序：<input type="text" name="orderNum"/>-->
							<!--</li>-->

							<li>
								服务状态：
								<select name="status" th:with="type=${@dict.getType('service_item')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
								<!--<input type="text" name="status"/>-->
							</li>

							<!--<li>-->
								<!--创建时间：<input type="text" name="createTime"/>-->
							<!--</li>-->

							<!--<li>-->
								<!--修改时间：<input type="text" name="updateTime"/>-->
							<!--</li>-->

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="item:serviceItems:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="item:serviceItems:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="item:serviceItems:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="item:serviceItems:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('item:serviceItems:edit')}]];
        var removeFlag = [[${@permission.hasPermi('item:serviceItems:remove')}]];
        var prefix = ctx + "item/serviceItems";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "服务项",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'siId', 
					title : '服务项主键'
					// visible: false
				},
				{
					field : 'deptName',
					title : '部门名称',
					sortable: true
				},
				// {
				// 	field : 'ancestors',
				// 	title : '祖级列表',
				// 	sortable: true
				// },
				{
					field : 'siName', 
					title : '服务项名称',
					sortable: true
				},
				{
					field : 'orderNum', 
					title : '显示顺序',
					sortable: true
				},
				{
					field : 'status', 
					title : '服务状态',
					sortable: true,
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '修改时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.siId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.siId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        /* 用户状态显示 */
        function statusTools(row) {
            if (row.state == 1) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.userId + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.userId + '\')"></i> ';
            }
        }
    </script>
</body>
</html>